Public Class MultiCurso

    Public Function obtenerCursos() As DataTable
        Dim dt As DataTable = New accesoBD.TripleCDataSetTableAdapters.selectCursosTableAdapter().GetData()
        Return dt
    End Function

    Public Function obtenerCurso(ByVal pidC As Integer) As Curso
        Dim idC As Integer
        Dim obj As Curso
        Dim nombre, codigo As String
        Dim dt As DataTable = New accesoBD.TripleCDataSetTableAdapters.selectCursoTableAdapter().GetData(pidC)
        idC = CInt(dt.Rows.Item(0).Item("idC"))
        nombre = CType(dt.Rows.Item(0).Item("nombre"), String)
        codigo = CType(dt.Rows.Item(0).Item("codigo"), String)
        obj = New Curso(idC, codigo, nombre)
        Return obj
    End Function


    Public Sub insertarCurso(ByVal pcod As String, ByVal pnom As String)
        Dim objC As New Curso(pcod, pnom)
        objC.insertese()
    End Sub

    Public Sub actualizarCurso(ByVal pidC As Integer, ByVal pcod As String, ByVal pnom As String)
        Dim objC As New Curso(pidC, pcod, pnom)
        objC.actualicese()
    End Sub

    Public Sub eliminarCurso(ByVal pidC As Integer)
        Try
            Dim da As New accesoBD.TripleCDataSetTableAdapters.QueriesTableAdapter
            da.deleteCurso(pidC)
        Catch ex As Exception
            Throw New ArgumentException("Existe grupos para este curso")
        End Try
        
    End Sub

End Class
